#ifndef _TRANS_COEFF_
#define _TRANS_COEFF_
#include "../DF_Common/basis_state.h"
#include "../DF_Common/coupling_coeff.h"
#include "../DF_Common/progress_bar.h"
#include <cmath>
#include <stdlib.h>
#include <vector>

using std::cout;
using std::endl;
using std::vector;

class TransCoeff {
public:
  TransCoeff(SixJ_coeff &sixJ_t, NinJ_coeff &ninJ_t, Hobra &hobra_t,
             Jacobi_NL &jaco_nl_t, SingleP &SP_t, TripleP &TP_t)
      : sixJ(sixJ_t), ninJ(ninJ_t), hobra_x(hobra_t), jaco_nl(jaco_nl_t),
        SP(SP_t), TP(TP_t) {}

  const SixJ_coeff &sixJ;
  const NinJ_coeff &ninJ;
  const Hobra &hobra_x;
  Jacobi_NL &jaco_nl;
  SingleP &SP;
  TripleP &TP;

  // vector<channel_TP> channel;
  vector<vector<double>> Tval_JTE; // Tval_JTE[jac][abc]
  vector<vector<vector<vector<double>>>>
      Tval_vec; // Tval_vec[channel_abc][0~TP.channel.Emax][index_jaco_nl][index_abc]
  vector<vector<vector<vector<int>>>>
      Tval_vec_flag; // Tval_vec[channel_abc][0~TP.channel.Emax][index_jaco_nl][index_abc]

  double cal(State_Jacobi &jaco, State_TP &triP);
  double cal2(State_Jacobi &jaco, State_TP &triP);
  double cal3(State_Jacobi &jaco, State_TP &triP);
  double cal4(State_Jacobi &jaco, State_TP &triP);
  double cal5(State_Jacobi &jaco, State_TP &triP);
  void build_JTE(int J2, int T2, int E);
  void build(); // Build Tval_vec[channel_abc][index_jaco_nl][index_abc]

  //  void build(int channel_start, int channel_end, int E);
  void print(std::string filename);

private:
  int phase(int n);
  int Tri(int &j2a, int &j2b, int &j2c);
  int Tri(int j2a, int j2b, int j2c);
};

#endif
